package org.dinnermate.staff;

import java.sql.SQLException;

import net.java.ao.DBParam;

import org.dinnermate.db.AbstractImplementation;
import org.dinnermate.db.DBManager;

public class ShiftImpl extends AbstractImplementation<Shift>
{
	public ShiftImpl( Shift shift )
	{
		super(shift);
	}

	public ShiftToStaff[] setStaffMembers( StaffMember[] staffMembers ) throws SQLException
	{
		this.deleteMaps(ShiftToStaff.class);
		
		ShiftToStaff[] maps = new ShiftToStaff[staffMembers.length];
		
		int x = 0;
		for (StaffMember sm : staffMembers)
		{
			maps[x++] = addStaffMember(sm);
		}
		
		return maps;
	}

	public ShiftToStaff addStaffMember( StaffMember staffMember ) throws SQLException
	{
		DBParam shift = new DBParam("shiftID", ao);
		DBParam sm = new DBParam("staffMemberID", staffMember);
		DBParam[] params = { shift, sm };
		return DBManager.getEntityManager().create(ShiftToStaff.class, params);
	}
}
